<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopFlowTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_flow', function (Blueprint $table) {
            $table->increments('id');

            $table->string('shop_id', 20)->default('')->comment('商户ID');
            $table->string('user_id', 20)->default('')->comment('用户ID');

            $table->string('order_num')->default('')->comment('订单号');
            $table->decimal('integral', 38, 4)->default(0)->comment('积分');
            $table->string('role_name')->default('')->comment('积分交易类型');
            $table->decimal('history', 38, 4)->default(0)->comment('历史积分');
            $table->integer('task_id')->default(0)->comment('任务ID');
            $table->integer('create_time')->default(0)->comment('创建时间');
            $table->integer('update_time')->default(0)->comment('更新时间');

            // 索引
            $table->index('shop_id');
            $table->index('user_id');
            $table->index('order_num');
            $table->index('task_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_flow');
    }
}
